#!/bin/sh

VERSION=$1

case $VERSION in
    ''|*[!0-9]*)
        echo "Usage: set-build-version numeric-build-version"
        exit 1
        ;;
    *)
        ;;
esac

if [ ! -d Client.xcodeproj ]; then
  echo "Please run this from the project root (where the .xcodeproj lives)"
  exit 1
fi

echo "Setting to $VERSION"

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSION" Client/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSION" Extensions/ShareTo/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSION" Extensions/SendTo/Info.plist
